<?php
	include "../../public/commom/config.php";
	include "../lock1.php";	
	
	if($_POST){
		$username = $_POST['username'];
		$password = $_POST['password'];
		
		$sql1 = "SELECT * FROM user WHERE username = '$username'";
		
		$result1 = mysqli_query($conn, $sql1);
		
		$num = mysqli_num_rows($result1);
		
		if(!$num) {
			$sql = "INSERT INTO user (username, password) VALUES ('$username', '$password')";
			
			$result = mysqli_query($conn, $sql);
			
			mysqli_close($conn);
				
			header("Location: ./index.php");
		} else {
			echo "用户名已存在";
		}
	}
?>